import axios from 'axios'
import { takeEvery, put } from 'redux-saga/effects'
import { API } from '../../config'
import { filter_products, filter_products_success } from '../actions/filter.action'

function* handleFilter_products(action) {
    const res = yield axios.post(`${API}/products/filter`, action.payload)
    yield put(filter_products_success({ skip: action.payload.skip, ...res.data }))
}

export default function* filterSaga() {
    yield takeEvery(filter_products, handleFilter_products)
}